package com.neutech.solar.client;

import com.neutech.solar.entity.*;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class SolarSystemClient extends AbstractFrame {
    public static void main(String[] args) {
        new SolarSystemClient();
    }
    public BackGround bg = new BackGround();
    public Star Sun = new Sun();
    public Planet Earth = new Planet(Sun,"Earth",1,0.0167,365,"地球");
    public Planet moon = new Planet(Earth,"smallPlanet",0.3,0.0,365/12,"");
    public Planet Mercury = new Planet(Sun,"Mercury",0.387,0.2056,88,"水星");
    public Planet Venus = new Planet(Sun,"Venus",0.72,0.0068,225,"金星",false,true);
    public Planet Mars = new Planet(Sun,"Mars",1.52,0.0934,687,"火星");
    public Planet Jupiter = new Planet(Sun,"Jupiter",5.2,0.0489,4330,"木星");
    public Planet Saturn = new Planet(Sun,"Saturn",9.54,0.0557,10832,"土星");
    public Planet Halley  = new Planet(Sun,"smallPlanet",30.06,0.0112,60328,"");

    public SolarSystemClient() {
        //super("太阳系八大行星");
        super.init("太阳系八大行星");
    }


        ArrayList<Planet> planets = new ArrayList<>();
    {
        Random random = new Random();
        for (int i = 0;i < 2000;i++) {
            double AU = random.nextDouble() * 2 + 2;
            double e = 0;
            int T = random.nextInt(3300) + 700;
            Planet smallPlanet = new Planet(Sun,"smallPlanet",AU,e,T,"",true,false);
            planets.add(smallPlanet);
        }
    }

    @Override
    public void paint(Graphics g) {
        bg.draw(g);
        Sun.draw(g);
        Earth.draw(g);
        moon.draw(g);
        Mercury.draw(g);
        Venus.draw(g);
        Mars.draw(g);
        for (Planet planet : planets) {
            planet.draw(g);
        }
        Jupiter.draw(g);
        Saturn.draw(g);
        Halley.draw(g);
    }


}
